package com.stylefeng.guns.modular.manager.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.core.datascope.DataScope;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.modular.system.model.GoodsUnit;
import com.stylefeng.guns.modular.system.dao.GoodsUnitMapper;
import com.stylefeng.guns.modular.manager.service.IGoodsUnitService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiuXin
 * @since 2018-09-12
 */
@Service
public class GoodsUnitServiceImpl extends ServiceImpl<GoodsUnitMapper, GoodsUnit> implements IGoodsUnitService {

    @Override
    public List<GoodsUnit> selectList(Wrapper<GoodsUnit> wrapper) {
        if(ShiroKit.isAdmin()){
            List<GoodsUnit> unitList = this.baseMapper.selectList(null);
            return unitList;
        }else {
            DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope());
            List<GoodsUnit> unitList = this.baseMapper.listGoodsUnit(dataScope);
            return unitList;
        }
    }
}
